<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>数组</title>
<!--     
        索引：0~最大数组长度-1
        数组长度：数组名.length
        数组高级运算符：...
            数组复制、合并数组、字符串转数组
            
        1.数组的声明
         let arr = new Array(数组长度);
         let arr = [数组长度];
         let arr = [值1, 值2, 值3]
         注意：数组长度是可变的
-->
</head>

<body>
    <script>
        // 1. 定义数组
        let arr = [10, 20, 30];
        alert(arr.length);

        // 2.遍历数组
        for (let index = 0; index < arr.length; index++) {
            document.write(arr[index] + "<br />");

        }
        document.write("==============<br>");

        // 3. 复制数组
        let arr2 = [...arr];    // 将arr数组复制到arr2数组
        for (let index = 0; index < arr2.length; index++) {
            document.write(arr[index] + "<br />");

        }
        document.write("==============<br>");

        // 4. 合并数组
        let arr3 = [40, 50, 60];
        let arr4 = [...arr2, ...arr3];
        //遍历数组
        for (let i = 0; i < arr4.length; i++) {
            document.write(arr4[i] + "<br>");
        }
        document.write("==============<br>");

        // 5. 将字符串转成数组
        //将字符串转成数组
        let arr5 = [..."heima"];
        //遍历数组
        for (let i = 0; i < arr5.length; i++) {
            document.write(arr5[i] + "<br>");
        }
    </script>
</body>

</html>